<script setup>
import { ref, onMounted } from 'vue'
import { deliveryList } from '@/apis/task.js'
import { userList } from '@/hooks/index.js'
// const list = ref([]);
// const nothing = ref(true);
const parmes = {
	page: 1,
	pageSize: 10,
	status: 1
}
const { getList, goButton, Refresh, list, isTriggered } = userList(deliveryList, parmes)

// 列表
// const ListApi = async () => {
// 	const { data } = await deliveryList(parmes);
// 	console.log('列表数据', data.items);
// 	list.value.push(...data.items);
// 	if (+data.counts === list.value.length) {
// 		nothing.value = false;
// 	}
// };

// // 上划加载更多 触底加载
// const goButton = () => {
// 	console.log('触底了');
// 	if (nothing.value === false) return;
// 	parmes.page++;
// 	ListApi();
// };
// 下拉刷新
</script>

<template>
	<scroll-view @scrolltolower="goButton" @refresherrefresh="Refresh" refresher-enabled :refresher-triggered="isTriggered" scroll-y class="scroll-view">
		<view class="scroll-view-wrapper">
			<view v-for="pickup in list" :key="pickup.id" class="task-card">
				<navigator hover-class="none" :url="`/subpkg_task/detail/index?id=${pickup.id}`">
					<view class="header">
						<text class="no">任务编号: {{ pickup.transportTaskId }}</text>
						<!-- <text class="status">已延迟</text> -->
					</view>
					<view class="body">
						<view class="timeline">
							<view class="line">{{ pickup.startAddress }}</view>
							<view class="line">{{ pickup.endAddress }}</view>
						</view>
					</view>
				</navigator>
				<view class="footer">
					<view class="label">提货时间</view>
					<view class="time">{{ pickup.planDepartureTime }}</view>
					<navigator v-if="pickup.enablePickUp" hover-class="none" :url="`/subpkg_task/pickup/index?id=${pickup.id}`" class="action">提货</navigator>
					<navigator v-else hover-class="none" url=" " class="action disabled">提货</navigator>
				</view>
			</view>
			<view v-if="list.length === 0" class="task-blank">无待提货物</view>
		</view>
	</scroll-view>
</template>

<style lang="scss" scoped>
@import './styles.scss';
</style>
